home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 1 / Amiga Tools.iso / wb-tools / toolmanager / source / library / rexx.c < prev    next >
C/C++ Source or Header  |  1994-06-06  |  1KB  |  56 lines

  1. /*
  2.  * rexx.c  V2.1
  3.  *
  4.  * ARexx support routines
  5.  *
  6.  * (c) 1990-1993 Stefan Becker
  7.  */
  8.  
  9. #include "ToolManagerLib.h"
  10.  
  11. /* ARexx library base */
  12. struct Library *RexxSysBase;
  13.  
  14. /* Send an ARexx command */
  15. BOOL SendARexxCommand(char *command, ULONG len)
  16. {
  17.  BOOL rc=FALSE;
  18.  
  19.  DEBUG_PRINTF("Send ARexx '%s'\n",command);
  20.  
  21.  /* Open ARexx system library */
  22.  if (RexxSysBase=OpenLibrary(RXSNAME,0)) {
  23.   struct RexxMsg *rxmsg;
  24.  
  25.   if (rxmsg=CreateRexxMsg(DummyPort,NULL,NULL)) {
  26.    if (rxmsg->rm_Args[0]=CreateArgstring(command,len)) {
  27.     struct MsgPort *ap; /* Port of ARexx resident process */
  28.  
  29.     /* Init Rexx message */
  30.     rxmsg->rm_Action=RXCOMM|RXFF_NOIO;
  31.  
  32.     /* Find port and send message */
  33.     Forbid();
  34.     ap=FindPort("AREXX");
  35.     if (ap) PutMsg(ap,(struct Message *) rxmsg);
  36.     Permit();
  37.  
  38.     /* Success? */
  39.     if (ap) {
  40.      /* Yes, wait on reply and remove it */
  41.      WaitPort(DummyPort);
  42.      GetMsg(DummyPort);
  43.  
  44.      /* Check return code */
  45.      rc=rxmsg->rm_Result1==RC_OK;
  46.     }
  47.  
  48.     ClearRexxMsg(rxmsg,1);
  49.    }
  50.    DeleteRexxMsg(rxmsg);
  51.   }
  52.   CloseLibrary(RexxSysBase);
  53.  }
  54.  return(rc);
  55. }
  56.